<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: base   dom.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1316139452.16" />
	<link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1316139452.16" />

    <script type="text/javascript" src="assets/api-js?stamp=1316139452.16"></script>
    <script type="text/javascript" src="assets/ac-js?stamp=1316139452.16"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="g-javascript-lib">g-javascript-lib</a></h1>
        <h3>base&nbsp; <span class="subtitle">1.0.0</span></h3>
        <a href="./index.html" title="g-javascript-lib">g-javascript-lib</a> 
            &gt; <a href="./module_base.html" title="base">base</a>
                
                 &gt; dom.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * @namespace DOM</span>
<span class="cm"> */</span>
<span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>

	<span class="nx">__Document</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>

	<span class="nx">G</span><span class="p">.</span><span class="nx">Namespace</span><span class="p">(</span><span class="s1">&#39;DOM&#39;</span><span class="p">);</span>

	<span class="cm">/**</span>
<span class="cm">	 * The externtions to standard DOM.</span>
<span class="cm">	 * @namespace DOM</span>
<span class="cm">	 * @class Element</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">GClass</span><span class="p">(</span><span class="s1">&#39;DOM&#39;</span><span class="p">,</span> <span class="s1">&#39;Element&#39;</span><span class="p">,</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Base</span><span class="p">.</span><span class="nx">EventListener</span><span class="p">);</span>

	<span class="cm">/**</span>
<span class="cm">	 * Constructure of DOM.Element</span>
<span class="cm">	 * @function __init</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__init</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">element</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">element</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Can&#39;t create DOM.Element on a undefined object&quot;</span><span class="p">);</span>
		<span class="p">}</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">__Base__EventListener__init</span><span class="p">();</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">em</span> <span class="o">=</span> <span class="nx">element</span><span class="p">;</span>
	<span class="p">};</span>

	<span class="cm">/**</span>
<span class="cm">	 *</span>
<span class="cm">	 * Get the mouse position offset to body of page in event report</span>
<span class="cm">	 * @method get_mouse</span>
<span class="cm">	 * @param ev {Event} The mouse event</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_mouse</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">ev</span><span class="p">.</span><span class="nx">pageX</span> <span class="o">||</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">pageY</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">return</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span><span class="nx">ev</span><span class="p">.</span><span class="nx">pageX</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">pageY</span><span class="p">};</span>
		<span class="p">}</span>
		<span class="k">return</span> <span class="p">{</span>
			<span class="nx">x</span><span class="o">:</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">clientX</span> <span class="o">-</span> <span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">scrollLeft</span> <span class="o">-</span> <span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">clientLeft</span><span class="p">,</span>
			<span class="nx">y</span><span class="o">:</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">clientY</span> <span class="o">-</span> <span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">scrollTop</span> <span class="o">-</span> <span class="nb">document</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">clientTop</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Get the top/left of the element offset to the page.</span>
<span class="cm">	 * @method get_offset_in_page</span>
<span class="cm">	 * @return {object} the </span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">get_offset_in_page</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> 
	<span class="p">{</span>
		<span class="kd">var</span> <span class="nx">l</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">offsetLeft</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">offsetTop</span><span class="p">;</span>

		<span class="k">for</span> <span class="p">(</span><span class="nx">p</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">offsetParent</span><span class="p">;</span> <span class="p">(</span><span class="nx">p</span> <span class="o">!=</span> <span class="kc">null</span> <span class="o">&amp;&amp;</span> <span class="nx">p</span><span class="p">.</span><span class="nx">tagName</span> <span class="o">!=</span> <span class="s2">&quot;body&quot;</span><span class="p">);</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">offsetParent</span><span class="p">){</span>
			<span class="nx">l</span> <span class="o">+=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">offsetLeft</span><span class="p">;</span>
			<span class="nx">t</span> <span class="o">+=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">offsetTop</span><span class="p">;</span> 
		<span class="p">}</span>
		<span class="k">return</span> <span class="p">{</span><span class="s1">&#39;left&#39;</span><span class="o">:</span> <span class="nx">l</span><span class="p">,</span> <span class="s1">&#39;top&#39;</span><span class="o">:</span> <span class="nx">t</span><span class="p">};</span>
	<span class="p">}</span>

	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__listen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evname</span><span class="p">)</span> 
	<span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">evname</span> <span class="o">==</span> <span class="s2">&quot;onresize&quot;</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">reg_resize_check</span><span class="p">();</span>
		<span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">evname</span> <span class="o">==</span> <span class="s2">&quot;ondrag&quot;</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">enable_drag</span><span class="p">();</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">_self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>

			<span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">)</span> <span class="p">{</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="nx">evname</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
					<span class="nx">ev</span> <span class="o">=</span> <span class="nx">ev</span> <span class="o">||</span> <span class="nb">window</span><span class="p">.</span><span class="nx">event</span><span class="p">;</span>
					<span class="nx">ev</span><span class="p">.</span><span class="nx">srcElement</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">srcElement</span> <span class="o">||</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">target</span><span class="p">;</span>
					<span class="nx">_self</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="nx">evname</span><span class="p">,</span> <span class="nx">ev</span><span class="p">);</span>
				<span class="p">},</span> <span class="kc">false</span><span class="p">);</span>
			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
				<span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">(</span><span class="nx">evname</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
					<span class="nx">ev</span> <span class="o">=</span> <span class="nx">ev</span> <span class="o">||</span> <span class="nb">window</span><span class="p">.</span><span class="nx">event</span><span class="p">;</span>
					<span class="nx">ev</span><span class="p">.</span><span class="nx">srcElement</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">srcElement</span> <span class="o">||</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">target</span><span class="p">;</span>
					<span class="nx">_self</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="nx">evname</span><span class="p">,</span> <span class="nx">ev</span><span class="p">);</span>
				<span class="p">});</span>
			<span class="p">}</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">__unlisten</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">evname</span><span class="p">)</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="nx">evname</span> <span class="o">==</span> <span class="s2">&quot;onresize&quot;</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">unreg_resize_check</span><span class="p">();</span>
		<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
			<span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">[</span><span class="nx">evname</span><span class="p">]</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
		<span class="p">}</span>
	<span class="p">}</span>
<span class="p">})();</span>


<span class="cm">/*</span>
<span class="cm"> * ============================= Drag ====================================</span>
<span class="cm"> */</span>
<span class="p">(</span><span class="kd">function</span><span class="p">(){</span>

	<span class="kd">var</span> <span class="nx">_dragObj</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">_mouseOffset</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">_dragOrig</span> <span class="o">=</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="mi">0</span><span class="p">};</span>
	<span class="kd">var</span> <span class="nx">_mouseOrig</span> <span class="o">=</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span> <span class="mi">0</span><span class="p">};</span>
	<span class="kd">var</span> <span class="nx">_lastPosition</span> <span class="o">=</span> <span class="p">{</span><span class="nx">x</span><span class="o">:</span><span class="mi">0</span><span class="p">,</span> <span class="nx">y</span><span class="o">:</span><span class="mi">0</span><span class="p">};</span>
	<span class="kd">var</span> <span class="nx">_dragLimit</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">_monitorMouseUp</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

	<span class="kd">function</span> <span class="nx">on_mouse_move</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
		<span class="nx">ev</span> <span class="o">=</span> <span class="nx">ev</span> <span class="o">||</span> <span class="nb">window</span><span class="p">.</span><span class="nx">event</span><span class="p">;</span>

		<span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">getSelection</span><span class="p">)</span> <span class="p">{</span>
			<span class="nb">window</span><span class="p">.</span><span class="nx">getSelection</span><span class="p">().</span><span class="nx">removeAllRanges</span><span class="p">();</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">_dragObj</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">pos</span> <span class="o">=</span> <span class="nx">G</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">get_mouse</span><span class="p">(</span><span class="nx">ev</span><span class="p">);</span>
			<span class="kd">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nx">_dragOrig</span><span class="p">.</span><span class="nx">y</span> <span class="o">+</span> <span class="p">(</span><span class="nx">pos</span><span class="p">.</span><span class="nx">y</span> <span class="o">-</span> <span class="nx">_mouseOrig</span><span class="p">.</span><span class="nx">y</span><span class="p">);</span>
			<span class="kd">var</span> <span class="nx">l</span> <span class="o">=</span> <span class="nx">_dragOrig</span><span class="p">.</span><span class="nx">x</span> <span class="o">+</span> <span class="p">(</span><span class="nx">pos</span><span class="p">.</span><span class="nx">x</span> <span class="o">-</span> <span class="nx">_mouseOrig</span><span class="p">.</span><span class="nx">x</span><span class="p">);</span>

			<span class="k">if</span> <span class="p">(</span><span class="nx">t</span> <span class="o">&lt;</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">minY</span><span class="p">)</span>	<span class="nx">t</span> <span class="o">=</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">minY</span><span class="p">;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">t</span> <span class="o">&gt;</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">maxY</span><span class="p">)</span>	<span class="nx">t</span> <span class="o">=</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">maxY</span><span class="p">;</span>

			<span class="k">if</span> <span class="p">(</span><span class="nx">l</span> <span class="o">&lt;</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">minX</span><span class="p">)</span>	<span class="nx">l</span> <span class="o">=</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">minX</span><span class="p">;</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">l</span> <span class="o">&gt;</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">maxX</span><span class="p">)</span>	<span class="nx">l</span> <span class="o">=</span> <span class="nx">_dragLimit</span><span class="p">.</span><span class="nx">maxX</span><span class="p">;</span>

			<span class="k">if</span> <span class="p">(</span><span class="nx">t</span> <span class="o">!=</span> <span class="nx">_lastPosition</span><span class="p">.</span><span class="nx">y</span> <span class="o">||</span> <span class="nx">l</span> <span class="o">!=</span> <span class="nx">_lastPosition</span><span class="p">.</span><span class="nx">x</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">_dragObj</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">top</span> <span class="o">=</span> <span class="nx">t</span><span class="p">;</span>
				<span class="nx">_dragObj</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">l</span><span class="p">;</span>

				<span class="nx">_lastPosition</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="nx">t</span><span class="p">;</span>
				<span class="nx">_lastPosition</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="nx">l</span><span class="p">;</span>

				<span class="nx">_dragObj</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="s2">&quot;ondrag&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;top&#39;</span><span class="o">:</span> <span class="nx">t</span><span class="p">,</span> <span class="s1">&#39;left&#39;</span><span class="o">:</span> <span class="nx">l</span><span class="p">});</span>
			<span class="p">}</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="kd">function</span> <span class="nx">on_mouse_up</span><span class="p">()</span> <span class="p">{</span>
		<span class="nx">_dragObj</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="p">}</span>

	<span class="kd">function</span> <span class="nx">get_limit</span><span class="p">(</span><span class="nx">em</span><span class="p">)</span> <span class="p">{</span>
		<span class="nx">p</span> <span class="o">=</span> <span class="nx">em</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">;</span>

	<span class="p">}</span>

	<span class="kd">var</span> <span class="nx">_drag_mouse_down</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">)</span> <span class="p">{</span>
		<span class="nx">ev</span> <span class="o">=</span> <span class="nx">ev</span> <span class="o">||</span> <span class="nb">window</span><span class="p">.</span><span class="nx">event</span><span class="p">;</span>
		<span class="nx">em</span> <span class="o">=</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">srcElement</span> <span class="o">||</span> <span class="nx">ev</span><span class="p">.</span><span class="nx">target</span><span class="p">;</span>

		<span class="c1">// Limit the drag in parent&#39;s client area.</span>
		<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">em</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">areaW</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">clientWidth</span><span class="p">;</span>
		<span class="kd">var</span> <span class="nx">areaH</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">clientHeight</span><span class="p">;</span>
		<span class="nx">_dragLimit</span> <span class="o">=</span> <span class="p">{</span>
			<span class="nx">minX</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
			<span class="nx">maxX</span><span class="o">:</span> <span class="nx">areaW</span> <span class="o">-</span> <span class="nx">em</span><span class="p">.</span><span class="nx">offsetWidth</span><span class="p">,</span>
			<span class="nx">minY</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span>
			<span class="nx">maxY</span><span class="o">:</span> <span class="nx">areaH</span> <span class="o">-</span> <span class="nx">em</span><span class="p">.</span><span class="nx">offsetHeight</span>
		<span class="p">}</span>

		<span class="nx">_dragObj</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
		<span class="nx">_dragOrig</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="nx">em</span><span class="p">.</span><span class="nx">offsetLeft</span><span class="p">;</span>
		<span class="nx">_dragOrig</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="nx">em</span><span class="p">.</span><span class="nx">offsetTop</span><span class="p">;</span>
		<span class="nx">_lastPosition</span><span class="p">.</span><span class="nx">x</span> <span class="o">=</span> <span class="nx">_dragOrig</span><span class="p">.</span><span class="nx">x</span><span class="p">;</span>
		<span class="nx">_lastPosition</span><span class="p">.</span><span class="nx">y</span> <span class="o">=</span> <span class="nx">_dragOrig</span><span class="p">.</span><span class="nx">y</span><span class="p">;</span>

		<span class="nx">_mouseOrig</span> <span class="o">=</span> <span class="nx">G</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">get_mouse</span><span class="p">(</span><span class="nx">ev</span><span class="p">);</span>
		<span class="nx">G</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onmousemove&quot;</span><span class="p">,</span> <span class="nx">on_mouse_move</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Enable the drag ability of the DomElement</span>
<span class="cm">	 * @method enable_drag</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">enable_drag</span><span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">_monitorMouseUp</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">G</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onmouseup&quot;</span><span class="p">,</span> <span class="nx">on_mouse_up</span><span class="p">);</span>
		<span class="p">}</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="s2">&quot;onmousedown&quot;</span><span class="p">,</span> <span class="nx">_drag_mouse_down</span><span class="p">);</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Disable the drag ability of the DomElement</span>
<span class="cm">	 * @method disable_drag</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">disable_drag</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">unbind</span><span class="p">(</span><span class="s2">&quot;onmousedown&quot;</span><span class="p">,</span> <span class="nx">_drag_mouse_down</span><span class="p">);</span>
	<span class="p">}</span>

<span class="p">})();</span>


<span class="cm">/*</span>
<span class="cm"> * ============================= Resize ====================================</span>
<span class="cm"> */</span>
<span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
	<span class="kd">var</span> <span class="nx">_targetList</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Utils</span><span class="p">.</span><span class="nx">List</span><span class="p">();</span>
	<span class="kd">var</span> <span class="nx">_resizeTimer</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
	<span class="kd">var</span> <span class="nx">_CHECK_INTERVAL</span> <span class="o">=</span> <span class="mi">200</span><span class="p">;</span>

	<span class="kd">var</span> <span class="nx">_check_resize</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">_targetList</span><span class="p">.</span><span class="nx">head</span><span class="p">;</span> <span class="nx">n</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">;</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
			<span class="kd">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">data</span><span class="p">;</span>
			<span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">clientWidth</span><span class="p">;</span>
			<span class="kd">var</span> <span class="nx">h</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">clientHeight</span><span class="p">;</span>

			<span class="k">if</span> <span class="p">(</span><span class="nx">w</span> <span class="o">!=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">currWidth</span> <span class="o">||</span> <span class="nx">h</span> <span class="o">!=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">currHeight</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">obj</span><span class="p">.</span><span class="nx">fire</span><span class="p">(</span><span class="s2">&quot;onresize&quot;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;w&#39;</span><span class="o">:</span> <span class="nx">w</span><span class="p">,</span> <span class="s1">&#39;h&#39;</span><span class="o">:</span> <span class="nx">h</span> <span class="p">});</span>
				<span class="nx">obj</span><span class="p">.</span><span class="nx">currWidth</span> <span class="o">=</span> <span class="nx">w</span><span class="p">;</span>
				<span class="nx">obj</span><span class="p">.</span><span class="nx">currHeight</span> <span class="o">=</span> <span class="nx">h</span><span class="p">;</span>
			<span class="p">}</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Regist the DomElement to system to check the resize event.</span>
<span class="cm">	 * @method reg_resize_check</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">reg_resize_check</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>

		<span class="k">this</span><span class="p">.</span><span class="nx">currWidth</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">clientWidth</span><span class="p">;</span>
		<span class="k">this</span><span class="p">.</span><span class="nx">currHeight</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">em</span><span class="p">.</span><span class="nx">clientHeight</span><span class="p">;</span>

		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">_targetList</span><span class="p">.</span><span class="nx">head</span><span class="p">;</span> <span class="nx">n</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">;</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">n</span><span class="p">.</span><span class="nx">data</span> <span class="o">==</span> <span class="k">this</span><span class="p">)</span> <span class="p">{</span>
				<span class="k">return</span><span class="p">;</span>
			<span class="p">}</span>
		<span class="p">}</span>

		<span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">G</span><span class="p">.</span><span class="nx">Utils</span><span class="p">.</span><span class="nx">ListNode</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
		<span class="nx">_targetList</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">n</span><span class="p">);</span>

		<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">_resizeTimer</span><span class="p">)</span> <span class="p">{</span>
			<span class="nx">_resizeTimer</span> <span class="o">=</span> <span class="nx">setInterval</span><span class="p">(</span><span class="nx">_check_resize</span><span class="p">,</span> <span class="nx">_CHECK_INTERVAL</span><span class="p">);</span>
		<span class="p">}</span>
	<span class="p">}</span>

	<span class="cm">/**</span>
<span class="cm">	 * Stop check the resize event of the element.</span>
<span class="cm">	 * @method unreg_resize_check</span>
<span class="cm">	 */</span>
	<span class="nx">G</span><span class="p">.</span><span class="nx">DOM</span><span class="p">.</span><span class="nx">Element</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">unreg_resize_check</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">_targetList</span><span class="p">.</span><span class="nx">head</span><span class="p">;</span> <span class="nx">n</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">;</span> <span class="nx">n</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
			<span class="k">if</span> <span class="p">(</span><span class="nx">n</span><span class="p">.</span><span class="nx">data</span> <span class="o">==</span> <span class="k">this</span><span class="p">)</span> <span class="p">{</span>
				<span class="nx">_targetList</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">n</span><span class="p">);</span>
				<span class="k">break</span><span class="p">;</span>
			<span class="p">}</span>
		<span class="p">}</span>

		<span class="k">if</span> <span class="p">(</span><span class="nx">_targetList</span><span class="p">.</span><span class="nx">is_empty</span><span class="p">())</span> <span class="p">{</span>
			<span class="nx">clearInterval</span><span class="p">(</span><span class="nx">_resizeTimer</span><span class="p">);</span>
			<span class="nx">_resizeTimer</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
		<span class="p">}</span>
	<span class="p">}</span>
<span class="p">}());</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class="selected"><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_svg.html" title="svg">svg</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class=""><a href="module_utils.html" title="utils">utils</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="DOM.Element.html" title="DOM.Element">DOM.Element</a></li>
                                <li class=""><a href="EventListener.html" title="EventListener">EventListener</a></li>
                                <li class=""><a href="G.html" title="G">G</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="board.js.html" title="board.js">board.js</a></li>
                                <li class="selected"><a href="dom.js.html" title="dom.js">dom.js</a></li>
                                <li class=""><a href="g.js.html" title="g.js">g.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"url": "EventListener.html#method_bind", "access": "", "host": "EventListener", "type": "method", "name": "bind"}, {"url": "DOM.Element.html#method_disable_drag", "access": "", "host": "DOM.Element", "type": "method", "name": "disable_drag"}, {"url": "DOM.Element.html#method_enable_drag", "access": "", "host": "DOM.Element", "type": "method", "name": "enable_drag"}, {"url": "EventListener.html#method_fire", "access": "", "host": "EventListener", "type": "method", "name": "fire"}, {"url": "G.html#method_GClass", "access": "", "host": "G", "type": "method", "name": "GClass"}, {"url": "DOM.Element.html#method_get_mouse", "access": "", "host": "DOM.Element", "type": "method", "name": "get_mouse"}, {"url": "DOM.Element.html#method_get_offset_in_page", "access": "", "host": "DOM.Element", "type": "method", "name": "get_offset_in_page"}, {"url": "G.html#method_get_uuid", "access": "", "host": "G", "type": "method", "name": "get_uuid"}, {"url": "DOM.Element.html#method___init", "access": "", "host": "DOM.Element", "type": "method", "name": "__init"}, {"url": "EventListener.html#method___listen", "access": "", "host": "EventListener", "type": "method", "name": "__listen"}, {"url": "G.html#method_Namespace", "access": "", "host": "G", "type": "method", "name": "Namespace"}, {"url": "DOM.Element.html#method_reg_resize_check", "access": "", "host": "DOM.Element", "type": "method", "name": "reg_resize_check"}, {"url": "EventListener.html#method_unbind", "access": "", "host": "EventListener", "type": "method", "name": "unbind"}, {"url": "EventListener.html#method___unlisten", "access": "", "host": "EventListener", "type": "method", "name": "__unlisten"}, {"url": "DOM.Element.html#method_unreg_resize_check", "access": "", "host": "DOM.Element", "type": "method", "name": "unreg_resize_check"}];
</script>
</body>
</html>
